/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */

class Solution
{
public:
    int int_max = INT_MAX;
    int secondmin = int_max;

    int findSecondMinimumValue(TreeNode *root)
    {
        if(!root || (root->left == NULL && root->right == NULL`)
            return -1;
        //遍历二叉树 
        int min = root->val;
        preOrder_toSecondMin(root,min);
        if(secondmin != tt)
            return secondmin;
        else
            return -1;
    }

    void preOrder_toSecondMin(TreeNode *root, int min)
    {
        if (root)
        {
            //判断 次小值的条件 
            //1. 不等于min
            //2. 新节点小于原来的次小值 则更新次小值 
            int t = root->val; //临时变量
            if (t != min)
            {
                if (secondmin > t)
                    secondmin = t;
            }
            preOrder_toSecondMin(root->left, min);
            preOrder_toSecondMin(root->right, min);
        }
    }
};